<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
      <el-form-item label="项目名称" prop="pName">
        <el-input v-model="queryParams.pName" placeholder="请输入项目名称" clearable size="mini" style="width: 240px" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="项目状态" prop="pStatus">
        <el-select v-model="queryParams.pStatus" placeholder="请选择项目状态" clearable size="mini" style="width: 240px">
          <el-option v-for="dict in dict.type.pm_status_type" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <div>
      <el-table v-loading="loading" :data="projectsList" size="mini">
          <el-table-column label="序号" align="center" type="index" width="120"/>
        <el-table-column label="项目名称" prop="pName" :show-overflow-tooltip="true" />
        <el-table-column label="项目状态" align="center" prop="createTime">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.pm_status_type" :value="scope.row.pStatus" />
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-view" @click="handleLookInfo(scope.row)">查看进度</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { listProjects } from "@/api/business/project/projects";
export default {
  name: "Info",
  components: {},
  dicts: ['pm_status_type'],
  data() {
    return {
      iShow: false,
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      projectsList: [],
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        pName: null,
        pStatus: null,
      },
    };
  },
  created() {
    this.getList();
  },
  mounted() {
  },
  methods: {
    /** 查询工程管理系统-工程项目信息列表 */
    getList() {
      this.loading = true;
      listProjects(this.queryParams).then(response => {
        this.projectsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleLookInfo(row) {
      this.$router.push({ name: "scheduleplan", query: { mainId: row.id } })
    }
  }
};
</script>